package com.hanamaki.dataStructDemo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ListAndMap {
    public static void main(String[] args) {

        List<Map<String, String>> list = new ArrayList<>();

        Map<String, String> map1 = new HashMap<>();
        Map<String, String> map2 = new HashMap<>();
        Map<String, String> map3 = new HashMap<>();
        Map<String, String> map4 = new HashMap<>();
        map1.put("1", "8");
        map1.put("2", "7");
        map2.put("3", "6");
        map2.put("4", "5");
        map3.put("5", "4");
        map3.put("6", "3");
        map4.put("7", "2");
        map4.put("8", "1");

        list.add(map1);
        list.add(map2);
        list.add(map3);
        list.add(map4);

        System.out.println(list);

        // 遍历 集合
        for (Map<String, String> map : list) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                System.out.println("当前key为："+entry.getKey()+",值为："+entry.getValue());
            }
        }

    }
}
